import java.util.Scanner;

public class Test {
    //前缀和
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int[] arr = new int[n+1];
            int q = in.nextInt();
            int[][] tmp = new int[q][2];
            //1.输入arr数组
            for(int i=1;i<n+1;i++) {
                arr[i] = in.nextInt();
            }
            for(int i=0;i<q;i++) {
                tmp[i][0]=in.nextInt();
                tmp[i][1]=in.nextInt();
            }
            long[] dp = new long[n+1];
            dp[0]=0;
            for(int i =1;i<n+1;i++) {
                dp[i]=dp[i-1]+arr[i];
            }
            for(int i=0;i<q;i++) {
                System.out.println(dp[tmp[i][1]]-dp[tmp[i][0]-1]);
            }
        }
    }
    //852.山脉数组的峰顶索引
    public int peakIndexInMountainArray(int[] arr) {
        int left = 0;
        int right = arr.length-1;
        while(left < right) {
            int mid = left+(right-left)/2;
            if(arr[mid] < arr[mid+1]) {
                left = mid+1;
            }else {
                right = mid;
            }
        }
        return right;
    }
}
